# -*- coding:utf-8 -*-
# @Time : 2020/11/23 16:00
# @Author: limeng
# @File : const.py
import sys


class Const:
    # 自定义异常处理
    class ConstError(TypeError):
        pass

    class ConstCaseError(ConstError):
        pass

    # 重写 __setattr__() 方法
    def __setattr__(self, name, value):
        if name in self.__dict__:  # 已包含该常量，不能二次赋值
            raise self.ConstError("can't change const %s" % name)
        if not name.isupper():  # 所有的字母需要大写
            raise self.ConstCaseError('const name "%s" is not all uppercase' % name)
        self.__dict__[name] = value


# 注入了一个Const对象从而实现了在执行import const时实际获取了一个Const实例
sys.modules[__name__] = Const()

# 返回值-自定义状态码-成功
Const.SUCCESS = 20000
# 返回值-自定义状态码-失败
Const.FAIL_40000 = 40000
# 返回值-自定义状态码-失败
Const.FAIL_50000 = 50000

# 钉钉扫码下包返回值-204
Const.SUCCESS_204 = 204
# 钉钉扫码下包返回值-400
Const.FAIL_400 = 400

# 编码-utf-8
Const.UTF_8 = "utf-8"

# 添加成功
Const.INSERT_SUCCESS = "添加成功"
# 添加失败
Const.INSERT_FAIL = "添加失败"
# 删除成功
Const.DELETE_SUCCESS = "删除成功"
# 删除失败
Const.DELETE_FAIL = "删除失败"
# 删除失败
Const.DELETE_FAIL_CASE_NON_EXISTENT = "删除失败,CASE不存在"
# 修改成功
Const.EDIT_SUCCESS = "修改成功"
# 修改失败
Const.EDIT_FAIL = "修改失败"
# 分页-页码
Const.PAGE_NUM = "page_num"
# 分页-每页数量
Const.PAGE_PER = "page_per"
# 查询成功
Const.QUERY_SUCCESS = "查询成功"
# 操作成功
Const.OPERATE_SUCCESS = "操作成功"
# 操作失败
Const.OPERATE_FAIL = "操作失败"

Const.PARAM_NOT_NULL = "参数不得为空"

"""
user
"""
# 返回值-TOKEN
Const.TOKEN = "token"
# 登录-默认用户头像
Const.DEFAULT_USER_AVATAR = "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif"
"""
report
"""
# 仪表盘-健康程度
Const.HEALTHY = "healthy"
# 仪表盘-健康程度函数数据返回结构KRY：success
Const.STR_SUCCESS = "success"
# 仪表盘-健康程度函数数据返回结构KRY：fail
Const.STR_FAIL = "fail"
# 仪表盘-bug排名
Const.BUG_SORT = "bugsort"
# 仪表盘-用例数
Const.IMPLEMENT = "implement"
# 仪表盘-CASE数量
Const.TOTAL_CASE = "total"
# 仪表盘-CASE数量
Const.TOTAL_CASE_NUM = "case数"
# 仪表盘-CASE数量统计图类型-bar/bug排名统计图类型-bar
Const.TOTAL_CASE_BAR = "bar"
# 仪表盘-构建统计图类型-line
Const.BUILD_COUNT_LINE = "line"
# 仪表盘-构建统计图纵坐标含义
Const.BUILD_COUNT_Y = "构建次数"
# 仪表盘-bug排名纵坐标含义
Const.BUG_SORT_Y = "bug数"
Const.DAYS = 14
# 可视化-reopen纵坐标含义
Const.REOPEN_BUG_COUNT_Y = "reopen bug数"
"""
task
"""
# 计划任务上传脚本-成功
Const.UPLOAD_FILE_SUCCESS = "上传成功"
# 计划任务上传脚本-失败
Const.UPLOAD_FILE_FAIL = "上传失败"
# 计划任务上传脚本-文件上传目标路径
Const.UPLOAD_LOCAL_TEST_PATH = "E:/tmp/"
# 计划任务上传脚本-文件上传目标路径
Const.UPLOAD_LINUX_PATH = "/data/cron/"
# 计划任务上传脚本-linux定时执行任务文件路径
Const.UPLOAD_LINUX_CRON_PATH = "/var/spool/cron/root"
# 计划任务-启动成功/CI任务管理-启动成功
Const.TASK_START_SUCCESS = "启动成功"
# 计划任务-启动失败/CI任务管理-启动失败
Const.TASK_START_FAIL = "启动失败"
# 计划任务/CI任务管理-停止成功
Const.TASK_STOP_SUCCESS = "停止成功"
# 计划任务/CI任务管理-停止失败
Const.TASK_STOP_FAIL = "停止失败"
# 计划任务-执行失败
Const.TASK_EXECUTE_FAIL = "执行失败"
# 计划任务-执行失败
Const.TASK_EXECUTE_SUCCESS = "执行成功"

# 部署环境-Windows
Const.WINDOWS = "Windows"
# 部署环境-Linux
Const.LINUX = "Linux"

"""
ci
"""
Const.D_TOKEN = "https://oapi.dingtalk.com/robot/send?access_token=7eb86685e144cb9a048f2a266c46b36dd458bec91ca9f2c1bbecf6b53a6e05ab"

"""
bug上报类型
"""
# bug上报类型-首轮测试
Const.FRIST_BUG = "首轮测试"
# bug上报类型-新发现
Const.MISS_BUG = "新发现"
# bug上报类型-新出现
Const.NEW_BUG = "新出现"
